package com.dq.domain.sys.j2cache;

import com.dq.domain.base.BaseEntity;

import com.dq.vo.baseVo.VO;
import com.dq.domain.sys.section.SysSection;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @创建人 gewenzhen
 * @创建时间 2019/10/22
 * @描述
 */
@Data
@Entity
public class Broadcast extends BaseEntity implements VO.ToVO {
    @ManyToOne
    protected SysSection org;

    protected String note;

    @Data
    public static class Vo implements VO {
        private Long id;
        private String note;
        @ApiModelProperty(value = "orgId")
        private Long orgId;
        @ApiModelProperty(value = "机构名")
        private String orgName;
        private String createTime;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.id;
        vo.note = fmt(this.note);
        vo.orgId = this.org != null ? this.org.getId() : null;
        vo.orgName = this.org != null ? this.org.getSimpleName() : "";
        vo.createTime = fmt(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        return vo;
    }
}
